package com.dobest.securitydemo.model.vo;

import com.dobest.securitydemo.model.domain.Role;
import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;

/**
 * Copyright © 2018胡建松. All rights reserved.
 *
 * @Package: com.dobest.securitydemo.model.vo
 * @author: hujiansong
 * @date: 2018/7/18 10:58
 * @version: V1.0
 */
@Data
public class UserDetail implements UserDetails {

    private Collection<? extends GrantedAuthority> authorities;

    private String username;

    private String password;

    private long lastPasswordChanged;

    private short enable;

    private Role role;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }

    @Override
    public String getPassword() {
        return password;
    }

    @Override
    public String getUsername() {
        return username;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return enable == 1;
    }
}
